package com.thiswhyme.republish.demo.rabbitmq;

import com.thiswhyme.republish.rabbitmq.core.AbstractRepublishHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;

/**
 * @description: 重发处理器demo
 * @author: thiswhyme
 * @date: 2021/1/27
 */
@Slf4j
public class DemoPublishAckHandler extends AbstractRepublishHandler {

    @ServiceActivator(inputChannel = "confirmAckSuccessChannel")
    @Override
    public void handleConfirm(Message<?> message) {
        handleConfirmForRepublish(message);
    }

    @Override
    public void doBizRepublishFail(Message<?> message, String outPutChannelName, String errMsg) {
        log.info("消息重发n次仍然失败，自定义处理（例如发送邮件通知人工介入），通道名：{}，内容：{}，错误内容：{}",
                outPutChannelName, message, errMsg);
    }

    @ServiceActivator(inputChannel = "destination.confirm-ack.errors")
    public void confirmFail(Message<?> message) {
        super.routeFail(message);
    }
}
